#!/usr/bin/python3.4
#-*- coding: utf-8 -*-
import paramiko

def copyfi(verno):
    try:
		ip = "10.1.1.50"
		username = "admin"
		passwd = "cisco"
		cmd = "show config"
		ssh = paramiko.SSHClient()
		ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
		ssh.connect(ip,22,username,passwd,timeout=5)
		stdin,stdout,stderr = ssh.exec_command(cmd)
		x = stdout.read().decode()
		configfiletmp = '/python/DCfile/' + verno + '/' + 'FI' + '.txt'
		configtmp = open(configfiletmp, 'w')
		configtmp.write(x)
		configtmp.close()
		print('%stOKn'%(ip))
		ssh.close()
	except:
		print('%stErrorn'%(ip))

if __name__ == '__main__':
	copyfi('v2')
